package jgl.vajra.kingkong.part.vehicle.viewModel;

import com.orhanobut.logger.Logger;

import java.util.Map;

import jgl.vajra.kingkong.part.vehicle.contract.ImmediatePaymentContract;
import jgl.vajra.kingkong.part.vehicle.contract.RechargeContract;
import jgl.vajra.kingkong.part.vehicle.model.RechargeModel;
import jgl.vajra.kingkong.widget.mvvm.factory.CreateModel;
import jgl.vajra.kingkong.widget.retrofithelper.rxsubscriber.ProgressObserver;

@CreateModel(RechargeModel.class)
public class RechargeViewModel extends RechargeContract.ViewModel{
    @Override
    public void getAccountBalanceData(Map<String, Object> map) {
        mModel.getAccountBalanceData(map).subscribe(new ProgressObserver<String>(true,this) {
            @Override
            public void _onNext(String data) {
                mView.returnAccountBalanceData(data);
            }

            @Override
            public void _onError(String errorMessage, int errorCode) {
                super._onError(errorMessage, errorCode);
            }
        });
    }

    @Override
    public void determinePaymentData(Map<String, Object> map) {
        mModel.determinePaymentData(map).subscribe(new ProgressObserver<Object>(true,this) {
            @Override
            public void _onNext(Object data) {
                mView.returnDeterminePaymentData();
            }

            @Override
            public void _onError(String errorMessage, int errorCode) {
                super._onError(errorMessage, errorCode);
            }
        });
    }

    @Override
    public void getRandomOrderNumber() {
        mModel.getRandomOrderNumber().subscribe(new ProgressObserver<String>(false, null) {
            @Override
            public void _onNext(String randomOrderNumber) {
                mView.returnRandomOrderNumberSuccess(randomOrderNumber);
            }

            @Override
            public void _onError(String errorMessage, int errorCode) {
                super._onError(errorMessage, errorCode);
                Logger.d("访问失败" + errorMessage);
            }
        });
    }
}

